import { Inject, Controller  , Post, Body} from '@midwayjs/decorator';
import { Context } from '@midwayjs/koa';
// import { Validate } from '@midwayjs/validate';
// import { loginDTO } from 'src/dto/login';
import { UserService } from 'src/service/user.service';
import { PayService } from 'src/service/onlypay.service';
import {  ApiBearerAuth, ApiHeader, ApiTags } from '@midwayjs/swagger';
import { OrderpayDTO } from 'src/dto/order';
import { LoginMiddleware } from 'src/middleware/userlogin';
import { Validate } from '@midwayjs/validate';


//  定义父路由  /user
@ApiHeader({
  name: 'authorization',
  description: 'token',
  // headers:'authorization'
})
@ApiTags(['支付'])
@ApiBearerAuth()
@Controller('/user/order' ,{ middleware: [ LoginMiddleware ]}  )
export class PayController {
  @Inject()
  ctx: Context;

  @Inject()
  UserService:UserService

  @Inject()
  PayService:PayService


  @Post('/pay')
  @Validate()
  async getnovel(@Body() body:OrderpayDTO) {
    console.log('body',body);
    
    //  return  'Hello Midwayjs12312312!'
        return this.PayService.userpay(body)
  }
}


